/*
 * @Author: ShiJunJie
 * @Date: 2022-04-01 14:33:50
 * @LastEditors: ShiJunJie
 * @LastEditTime: 2022-04-13 16:32:18
 * @Descripttion: 
 */
/**
 * =========================================================================
 * 扩展插件作用：实现vue自动化路由与布局
 * ----------------------------------------------------------------------
 * 读取 src/views 文件夹下的vue文件,生成vue-router的路由信息
 * 结合 src/layouts 布局文件进行自动化生成vue-router路由布局
 * =========================================================================
 */
import Pages from 'vite-plugin-pages'
import Layouts from 'vite-plugin-vue-layouts'

export default (options?: viteUserOptions): viteUserPlugins => {
  const plugins = [
    // [基于文件系统的Vite路由生成器](https://github.com/hannoeru/vite-plugin-pages)
    Pages({
      pagesDir: [
        { dir: 'src/views/default', baseRoute: '' },
        { dir: 'src/views/async', baseRoute: 'async' }
      ],
      extensions: ['vue', 'md', 'tsx'],
      exclude: ['**/components/*']
      // nuxtStyle: true
    }),

    // [自动化路由布局](https://github.com/JohnCampionJr/vite-plugin-vue-layouts)
    Layouts({
      layoutsDirs: ['src/layouts', 'src/layouts/Basic'], //默认布局文件目录位置
      // defaultLayout: 'BasicLayout' //默认布局，新增布局文件要重启vite
      defaultLayout: 'LayoutLR' //默认布局，新增布局文件要重启vite
    })
  ]
  return { plugins }
}
